package com.jhl.seckill.vo;


import lombok.AllArgsConstructor;
import lombok.Data;


/**
 * 自定义返回的响应对象
 */
@Data
@AllArgsConstructor
public class RespBean {
    // 状态码   响应消息  对象
    private long code;
    private String message;
    private Object object;

    public static RespBean success() {
        return new RespBean(RespBeanEnum.SUCCESS.getCode(), RespBeanEnum.SUCCESS.getMessage(), null);
    }

    public static RespBean success(Object object) {
        return new RespBean(RespBeanEnum.SUCCESS.getCode(), RespBeanEnum.SUCCESS.getMessage(), object);
    }

    public static RespBean error(RespBeanEnum respBeanEnum) {
        return new RespBean(respBeanEnum.getCode(), respBeanEnum.getMessage(), null);
    }

    public static RespBean error(RespBeanEnum respBeanEnum, Object object) {
        return new RespBean(respBeanEnum.getCode(), respBeanEnum.getMessage(), object);
    }

    public static RespBean loginFailed(Object object) {
        return new RespBean(RespBeanEnum.LOGIN_ERROR.getCode(), RespBeanEnum.LOGIN_ERROR.getMessage(), object);
    }

    public static RespBean passwordError(Object object) {
        return new RespBean(RespBeanEnum.PASSWORD_ERROR.getCode(), RespBeanEnum.PASSWORD_ERROR.getMessage(), object);
    }

    public static RespBean userNotExistsError(Object object) {
        return new RespBean(RespBeanEnum.USER_ERROR.getCode(), RespBeanEnum.USER_ERROR.getMessage(), object);

    }
}
